package com.hzw.saas.api.property.enmus;

import cn.hutool.core.lang.Assert;

import java.util.Objects;

/**
 * 系统字典key
 *
 * @author zzl
 * @since 09/13/2021
 */
public enum SysDictKeyEnum {

    BLANK(SysDictModuleEnum.BLANK.getModule(), "", ""),

    SELLER_NAME(SysDictModuleEnum.CUSTOMER.getModule(), "sellerName", "默认销售姓名"),
    SELLER_PHONE(SysDictModuleEnum.CUSTOMER.getModule(), "sellerPhone", "默认销售手机号"),
    SELLER_EMAIL(SysDictModuleEnum.CUSTOMER.getModule(), "sellerEmail", "默认销售邮箱"),

    DEFAULT_LEVEL_ID(SysDictModuleEnum.CUSTOMER_LEVEL.getModule(), "defaultLevelId", "默认会员级别ID"),
    EMAIL_LEVEL_ID(SysDictModuleEnum.CUSTOMER_LEVEL.getModule(), "emailLevelId", "普通邮箱会员级别ID"),
    PHONE_LEVEL_ID(SysDictModuleEnum.CUSTOMER_LEVEL.getModule(), "phoneLevelId", "普通手机号会员级别ID"),
    EDU_LEVEL_ID(SysDictModuleEnum.CUSTOMER_LEVEL.getModule(), "eduLevelId", "教育会员级别ID"),
    EDU_EMAIL_SUFFIX(SysDictModuleEnum.CUSTOMER_LEVEL.getModule(), "eduEmailSuffix", "教育邮箱后缀"),
    DYNAMIC_LEVELS(SysDictModuleEnum.CUSTOMER_LEVEL.getModule(), "dynamicLevels", "可触发式(随手机号或EDU邮箱变更)等级列表"),

    CHANNEL_A(SysDictModuleEnum.CHANNEL.getModule(), "A", "用户注册"),
    CHANNEL_B(SysDictModuleEnum.CHANNEL.getModule(), "B", "后台开通"),
    CHANNEL_C(SysDictModuleEnum.CHANNEL.getModule(), "C", "销售在线推广"),
    CHANNEL_D(SysDictModuleEnum.CHANNEL.getModule(), "D", "单机软件"),
    CHANNEL_E(SysDictModuleEnum.CHANNEL.getModule(), "E", "线上促销推广"),
    CHANNEL_F(SysDictModuleEnum.CHANNEL.getModule(), "F", "线下活动扫码"),

    RELATION_1(SysDictModuleEnum.RELATION.getModule(), "1", "专属客服"),
    RELATION_2(SysDictModuleEnum.RELATION.getModule(), "2", "推广销售"),

    SUB_TYPE_0(SysDictModuleEnum.PRODUCT_SUB_TYPE.getModule(), "0", "鸿之微云"),
    SUB_TYPE_1(SysDictModuleEnum.PRODUCT_SUB_TYPE.getModule(), "1", "软件计算"),
    SUB_TYPE_2(SysDictModuleEnum.PRODUCT_SUB_TYPE.getModule(), "2", "工具使用"),
    SUB_TYPE_3(SysDictModuleEnum.PRODUCT_SUB_TYPE.getModule(), "3", "数据助力"),

    REGISTER_URI(SysDictModuleEnum.STAFF.getModule(), "registerURI", "移动端注册首页"),
    LOGO_URL(SysDictModuleEnum.STAFF.getModule(), "logoUrl", "移动端注册首页"),

    LACKED_HPC_TIME(SysDictModuleEnum.HPC.getModule(), "lackedHpcTime", "补充核时提醒阈值"),
    INTERVAL_TIME(SysDictModuleEnum.HPC.getModule(), "intervalTime", "HPC刷新明细间隔时间(秒)"),
    SHARE_HPC_EXPIRE_TIME(SysDictModuleEnum.HPC.getModule(), "shareHpcExpireTime", "HPC共享帐号过期时间(月)"),
    PROVIDER_TYPE(SysDictModuleEnum.HPC.getModule(), "providerType", "供应商"),

    PARALLEL_MODEL_1(SysDictModuleEnum.PRODUCT_PARALLEL_MODEL.getModule(), "1", "GUI界面"),
    PARALLEL_MODEL_2(SysDictModuleEnum.PRODUCT_PARALLEL_MODEL.getModule(), "2", "本地计算"),
    PARALLEL_MODEL_3(SysDictModuleEnum.PRODUCT_PARALLEL_MODEL.getModule(), "3", "本地图形"),
    PARALLEL_MODEL_4(SysDictModuleEnum.PRODUCT_PARALLEL_MODEL.getModule(), "4", "远程计算"),
    PARALLEL_MODEL_7(SysDictModuleEnum.PRODUCT_PARALLEL_MODEL.getModule(), "7", "远程图形"),

    VERIFY_LOCK_TIME(SysDictModuleEnum.EXPIRE_TIME.getModule(), "verifyLockTime", "验证请求发送允许时间间隔，单位：秒"),
    VERIFY_DURATION(SysDictModuleEnum.EXPIRE_TIME.getModule(), "verifyDuration", "验证码(短信，邮件)有效时间，单位：秒"),

    DATA_MIGRATION_SPACE(SysDictModuleEnum.STORAGE.getModule(), "dataMigrationSpace", "冷热数据迁移的存储空间"),
    HOT_DATA_PERIOD(SysDictModuleEnum.STORAGE.getModule(), "hotDataPeriod", "热数据期限, 单位：m,H,d,M,y,无单位时默认为d"),

    RESEARCH_DIRECTION_JSON(SysDictModuleEnum.PROJECT_APPLY.getModule(), "researchDirection", ""),

    TRIAL_TEMPLATE_KEY(SysDictModuleEnum.HPC_CONTRACT_TEMPLATE.getModule(), "trialTemplate", ""),

    SLURM_ACCOUNTS(SysDictModuleEnum.HPC_QINGYUN.getModule(), "slurm.accounts", ""),
    DEVICE_STUDIO_SUPPORT(SysDictModuleEnum.DEVICE_STUDIO.getModule(), "support.url", "support接入地址"),
    WELCOME_MSG(SysDictModuleEnum.WEB_SHELL.getModule(), "welcome.msg", ""),
    TICKET_API(SysDictModuleEnum.TICKET.getModule(), "ticket.api", "");

    private final String module;
    private final String key;
    private final String text;

    SysDictKeyEnum(String module, String key, String text) {
        this.module = module;
        this.key = key;
        this.text = text;
    }

    public String getModule() {
        return module;
    }

    public String getKey() {
        return key;
    }

    public String getText() {
        return text;
    }

    public static void assertValid(String module, String key) {
        SysDictKeyEnum instance = instance(module, key);
        Assert.notNull(instance, "系统字典值未知：{module: {}, key: {}}", module, key);
    }

    public static SysDictKeyEnum instance(String module, String key) {
        for (SysDictKeyEnum instance : SysDictKeyEnum.values()) {
            if (Objects.equals(instance.getModule(), module)
                && Objects.equals(instance.getKey(), key)) {
                return instance;
            }
        }
        return null;
    }

}
